﻿using Api.Application.Command.RoleMenu;
using Api.DTO;
using ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers
{
    /// <summary>
    /// 角色菜单中间表
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class RoleMenuController : ControllerBase
    {
        private readonly IMediator mediator;

        public RoleMenuController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 角色分配菜单
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddRoleMenu(AddRoleMenuCommand request)
        {
            return mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiResult<List<int>>> GetRoleMenu([FromQuery]GetRoleMenuCommand request)
        {
            return mediator.Send(request);
        }
    }
}
